package com.buka.communicate.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.CardView;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.buka.communicate.R;
import com.buka.communicate.adapter.SkillAdapter;
import com.buka.communicate.adapter.SkillDetailAdapter;

import net.neiquan.applibrary.base.BaseActivity;

import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.OnClick;

/**
 * Created by Administrator on 2017/11/15 0015.
 */

public class SkillDetailActivity extends BaseActivity {
    @InjectView(R.id.mRecylerView)
    RecyclerView mRecylerView;
    @InjectView(R.id.skillLogo)
    ImageView skillLogo;
    @InjectView(R.id.skillName)
    TextView skillName;
    @InjectView(R.id.skillLevel)
    TextView skillLevel;
    @InjectView(R.id.skillStars)
    ImageView skillStars;
    @InjectView(R.id.currentEffect)
    TextView currentEffect;
    @InjectView(R.id.upEffect)
    TextView upEffect;
    @InjectView(R.id.mProgressBar)
    ProgressBar mProgressBar;
    @InjectView(R.id.practiseHint)
    TextView practiseHint;
    @InjectView(R.id.expendLogo1)
    ImageView expendLogo1;
    @InjectView(R.id.expendChosen1)
    FrameLayout expendChosen1;
    @InjectView(R.id.expendNum1)
    TextView expendNum1;
    @InjectView(R.id.successRate1)
    TextView successRate1;
    @InjectView(R.id.expendLogo2)
    ImageView expendLogo2;
    @InjectView(R.id.expendChosen2)
    FrameLayout expendChosen2;
    @InjectView(R.id.expendNum2)
    TextView expendNum2;
    @InjectView(R.id.successRate2)
    TextView successRate2;
    @InjectView(R.id.expendLogo3)
    ImageView expendLogo3;
    @InjectView(R.id.expendChosen3)
    FrameLayout expendChosen3;
    @InjectView(R.id.expendNum3)
    TextView expendNum3;
    @InjectView(R.id.successRate3)
    TextView successRate3;
    @InjectView(R.id.costLogo1)
    ImageView costLogo1;
    @InjectView(R.id.costChosen1)
    FrameLayout costChosen1;
    @InjectView(R.id.costNum1)
    TextView costNum1;
    @InjectView(R.id.costRate1)
    TextView costRate1;
    @InjectView(R.id.costLogo2)
    ImageView costLogo2;
    @InjectView(R.id.costChosen2)
    FrameLayout costChosen2;
    @InjectView(R.id.costNum2)
    TextView costNum2;
    @InjectView(R.id.costRate2)
    TextView costRate2;
    @InjectView(R.id.costLogo3)
    ImageView costLogo3;
    @InjectView(R.id.costChosen3)
    FrameLayout costChosen3;
    @InjectView(R.id.costNum3)
    TextView costNum3;
    @InjectView(R.id.costRate3)
    TextView costRate3;
    @InjectView(R.id.currentSuccessRate)
    TextView currentSuccessRate;
    @InjectView(R.id.basicSuccessRate)
    TextView basicSuccessRate;
    @InjectView(R.id.successRateHint)
    TextView successRateHint;
    @InjectView(R.id.levelUpNow)
    CardView levelUpNow;

    @Override
    public int getRootViewId() {
        return R.layout.activity_skill_detail;
    }

    @Override
    public void setViews() {
        setTitleTv("技能详情");
        initRecylerView();
    }

    private void initRecylerView() {
        LinearLayoutManager mLayoutManager =
                new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false);
        mRecylerView.setLayoutManager(mLayoutManager);
        mRecylerView.setAdapter(new SkillDetailAdapter(this, null));
    }

    @Override
    public void initData() {

    }

    @OnClick({R.id.practiseHint, R.id.expendChosen1, R.id.expendChosen2, R.id.expendChosen3, R.id.costChosen1, R.id.costChosen2, R.id.costChosen3, R.id.successRateHint, R.id.levelUpNow})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.practiseHint:
                startActivity(new Intent(SkillDetailActivity.this,PractiseRateActivity.class));
                break;
            case R.id.expendChosen1:
                changeChosenBg(expendChosen1);
                break;
            case R.id.expendChosen2:
                changeChosenBg(expendChosen2);
                break;
            case R.id.expendChosen3:
                changeChosenBg(expendChosen3);
                break;
            case R.id.costChosen1:
                changeCostBg(costChosen1);
                break;
            case R.id.costChosen2:
                changeCostBg(costChosen2);
                break;
            case R.id.costChosen3:
                changeCostBg(costChosen3);
                break;
            case R.id.successRateHint:
                startActivity(new Intent(SkillDetailActivity.this,SuccessRateActivity.class));
                break;
            case R.id.levelUpNow:
                break;
        }
    }

    private void changeChosenBg(FrameLayout mChosenFL) {
        expendChosen1.setBackground(null);
        expendChosen2.setBackground(null);
        expendChosen3.setBackground(null);
        mChosenFL.setBackground(getResources().getDrawable(R.drawable.shape_blue_dashed));
    }

    private void changeCostBg(FrameLayout mChosenFL) {
        costChosen1.setBackground(null);
        costChosen2.setBackground(null);
        costChosen3.setBackground(null);
        mChosenFL.setBackground(getResources().getDrawable(R.drawable.shape_blue_dashed));
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.inject(this);
    }
}
